﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Red.Controls.Converters
{
    public sealed class NumberToPercentConverter : IValueConverter
    {
        #region IValueConverter implementation

        public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            double result = 0;
            if ( value is double || value is float || value is int )
            {
                result = (double)value * 100;
            }
            return result;
        }

        public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            double result = 0;
            if ( value is double || value is float || value is int )
            {
                result = (double)value / 100;
            }
            return result;
        }
        #endregion IValueConverter implementation
    }
}
